package com.rtf.framework.mq.rocketmq.consumer.listener;

import java.util.List;

import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
import org.apache.rocketmq.common.message.MessageExt;

import com.rtf.framework.mq.common.BatchMessageConsumer;

public class BatchMessageConsumerCurrentlyListener implements MessageListenerConcurrently {

	private BatchMessageConsumer consumer;

	public BatchMessageConsumerCurrentlyListener(BatchMessageConsumer consumer) {
		this.consumer = consumer;
	}

	@Override
	public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) {

		boolean result = this.consumer.onMessageRocket(msgs);
		if (result)
			return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
		else
			return ConsumeConcurrentlyStatus.RECONSUME_LATER;
	}

}
